home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_exmh.idb / usr / freeware / lib / exmh-2.5 / text.tcl.z / text.tcl
Text File  |  2002-07-08  |  2KB  |  55 lines

  1. # text.tcl
  2. #
  3. # Some (more) basic text utilities.
  4. #
  5. # Copyright (c) 1994 Xerox Corporation.
  6. # Use and copying of this software and preparation of derivative works based
  7. # upon this software are permitted. Any distribution of this software or
  8. # derivative works must comply with all applicable United States export
  9. # control laws. This software is made available AS IS, and Xerox Corporation
  10. # makes no warranty about the software, its performance or its conformity to
  11. # any specification.
  12.  
  13. proc Text_TagRangeHigh { t start end args } {
  14.     # This adds the tags named in args to the given range
  15.     # The tags are added at high priority, which is
  16.     # appropriate for "looks" tags and the selection
  17.     foreach tag $args {
  18.     $t tag add $tag $start $end
  19.     $t tag raise $tag    ;# over background tags
  20.     }
  21. }
  22. proc Text_TagRangeLow { t start end args } {
  23.     # This adds the tags named in args to the given range
  24.     # The tags are added at low priority, which is
  25.     # appropriate for backgrounds
  26.     foreach tag $args {
  27.     $t tag add $tag $start $end
  28.     $t tag lower $tag    ;# Under selection and looks
  29.     }
  30. }
  31. proc Text_TagRangeOverride { t start end args } {
  32.     # This replaces tags in a range.
  33.     # Each tag in args that has the pattern foo=bar
  34.     # replaces any existing tags foo=baz
  35.     # in the range
  36.     set labels {}
  37.     foreach tag $args {
  38.     if [regexp {([^=]+)=} $tag match label] {
  39.         lappend labels $label
  40.     }
  41.     }
  42.     foreach tag [concat [$t tag names $start] [$t tag names $end]] {
  43.     foreach label $labels {
  44.         if [string match $label=* $tag] {
  45.         $t tag remove $tag $start $end
  46.         }
  47.     }
  48.     }
  49.     foreach tag $args {
  50.     $t tag add $tag $start $end
  51.     $t tag lower $tag    ;# Under selection and looks
  52.     }
  53.     return $labels
  54. }
  55.